package cn.elwy.rcp.ui.explorer.project;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;

public class CNFProjectNature implements IProjectNature {

  public static final String ID = "cn.elwy.rcp.ui.explorer.CNFProjectNature";

  private IProject project;

  @Override
  public void configure() throws CoreException {
    IProjectDescription description = project.getDescription();
    ProjectUtil.addBuilderToProject(description, new String[] { CNFProjectBuilder.ID }, null);
    project.setDescription(description, null);
  }

  @Override
  public void deconfigure() throws CoreException {
    IProjectDescription description = project.getDescription();
    ProjectUtil.removeBuilderFromProject(description, new String[] { CNFProjectBuilder.ID }, null);
    project.setDescription(description, null);
  }

  @Override
  public IProject getProject() {
    return this.project;
  }

  @Override
  public void setProject(IProject project) {
    this.project = project;
  }

}
